<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>入库</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta http-equiv="Cache-Control" content="no-transform">
		<meta name="format-detection" content="telephone=no">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<link rel="stylesheet" href="style/css/basic.css" />
		<link rel="stylesheet" href="style/css/bound.css" />
		<script type="text/javascript" src="style/plugin/mui/js/mui.min.js"></script>
		<script type="text/javascript" src="style/js/jquery-1.8.3.min.js" ></script>
		<script type="text/javascript" src="style/mockjs/dist/mock.js"></script>
		<script type="text/javascript" src="style/js/vue.min.js"></script>
		<script type="text/javascript" src="style/js/vue-resource.js"></script>
		<script type="text/javascript" src="style/js/basic.js"></script>
	</head>
	<body>
		<div id="sales_bound">
		    <div id="header">
				<h1>待入库</h1>
			</div>
			<!--content-->
			<div class="body" id="refreshContainer">
				<div class="in_bound" v-for="(bnd,index) in boundMsg" v-if="boundMsg!=''">
					<div class="order_num">
						<a href="" class="nextArrow">
							<span>订单编号：{{bnd.order_no}}</span>
							<span class="fr gray time">{{fTime(bnd.check_time)}}</span>
						</a>				
					</div>
					<!--<div>
						<span>XX经销商购买20瓶</span>
						<a href="merchandise.html" class="btn_r">查看商品</a>
					</div>-->
					<div>
						<span>未入库：{{bnd.num}}瓶</span>
						<a href="javascript:;" class="btn_r" @tap="jumpScanin(index)">入库</a>
					</div>
				</div>			
			</div>
			<!--footer-->
			<div id="footer">
				<ul class="clearfix">
					<li>
						<a href='sales_in_bound.html'><i class="icon_scan"></i><span class="active_color">待入库</span></a>
					</li>
					<li>
						<a href="sales_verification.html"><i class="icon_verification"></i><span>核销</span></a>
					</li>
					<li>
						<a href='sales_integral_mall.html'><i class="icon_integral"></i><span>积分</span></a>
					</li>
					<li>
						<a href='sales_my.html'><i class="icon_my"></i><span>我的</span></a>
					</li>
				</ul>
			</div>	
		</div>
		<script>
			new Vue({
				el:"#sales_bound",
				data:{
					boundMsg:"",
					ticket:"",
				    sign:""
				},
				methods:{
					fTime:function(timestamp){
	                	if (typeof timestamp == "undefined") {
					        timestamp = Math.round(new Date().getTime() / 1000)
					    }
					    var n = parseInt(timestamp) * 1000
					    var date = new Date(n);
					    var Y = date.getFullYear() + '-';
					    var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
					    var D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
					    var H=date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
					    var Min=date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
					    var S=date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
					    return (Y + M + D)
	                },
	                jumpScanin:function(sIndex){
	                	alert(1)
	               	    openurl_can("scan_in",this.boundMsg[sIndex].order_no)
	                }
				},
				created:function(){
					var p=1;
					var that=this; 
					this.ticket=localStorage.getItem("tick")
                    this.sign=localStorage.getItem("sig")
					mui.plusReady(function(){
						mui.init({
						  pullRefresh : {
						    container:"#refreshContainer",//下拉刷新容器标识，querySelector能定位的css选择器均可，比如：id、.class等
						    down : {
						      style:'circle',//必选，下拉刷新样式，目前支持原生5+ ‘circle’ 样式
						      color:'#2BD009', //可选，默认“#2BD009” 下拉刷新控件颜色
						      height:'50px',//可选,默认50px.下拉刷新控件的高度,
						      range:'100px', //可选 默认100px,控件可下拉拖拽的范围
						      offset:'0px', //可选 默认0px,下拉刷新控件的起始位置
						      contentdown:null,
						      auto: true,//可选,默认false.首次加载自动上拉刷新一次
						      callback :pullrefesh  	      
						    }
						  }
						}); 
					})
					function pullrefesh(){
						that.$http.post(domain+"/saler/getUnSalerOrderList?t="+that.ticket+"&sign="+that.sign,{
						      	page_id:p++,
						      	page_size:2
						      },{emulateJSON:true}).then(
					            function (res) {
					                // 处理成功的结果
					                console.log(res.body)
					                if(res.body.code==1){
					                	if(res.body.data.list.length==0){  
						                	mui.toast("没有更多了")
						                	return false;
						                }
					                    that.boundMsg=res.body.data.list;
					                    console.log(that.boundMsg)
					                }else{
					                	mui.toast("暂无商品")
					                }
					            },function (res) {
					            // 处理失败的结果
					            console.log(res) 
					            }
					        ).then(function(){
					        	mui('#refreshContainer').pullRefresh().endPulldownToRefresh();   
					        });
						
					}
				},
				mounted:function(){
					mui.plusReady(function(){
			
			//          var wvs = plus.webview.all();//获取所有的窗口
			//        plus.webview.close(wvs[0]);//关闭欢迎页
			
			    //首页返回键处理  
			            //处理逻辑：2秒内，连续两次按返回键，则退出应用  
			            var first = null;  
			            mui.back=function(){
			            if(!first){  
			                    first = new Date().getTime();  
			                    mui.toast('再按一次退出应用');  
			                    setTimeout(function(){  
			                        first = null;  
			                    },2000);  
			                } else {  
			                    if(new Date().getTime() - first < 2000){  
			                        plus.runtime.quit();
			                        localStorage.removeItem("custInfo");
			                    }  
			                }  
			            }; 
			        })
				}
			})
		</script>
	</body>
</html>
